import java.util.ArrayList;
import java.util.Scanner;

public class jinzhi {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();

        double sum=0;


        for (int i = 2; i <line.length() ; i++) {
            char a = line.charAt(i);
            int b = 0;
            if (a>='0'&&a<='9'){
                b=a-'0';
                double c = b * Math.pow(16, line.length() - 1 - i);
                sum+=c;
            }
            if (a>='A'){
                b=a-'A'+10;
                double c = b * Math.pow(16, line.length() - 1 - i);
                sum+=c;

            }




        }

        int sum01=(int)sum;





        System.out.println(sum01);









    }


}
